<div class="adPosts index">
<h2><?php __('Ads Listing') ;?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
	<th><?php echo $paginator->sort(__('Id',true), 'id');?></th>
	<th><?php echo $paginator->sort(__('Category',true), 'ad_category_id');?></th>
	<th><?php echo $paginator->sort(__('Type',true), 'type');?></th>
	<th><?php echo $paginator->sort(__('Title',true), 'title');?></th>
	<th><?php echo $paginator->sort(__('Description',true), 'description');?></th>
	<th><?php echo $paginator->sort(__('Price',true), 'price');?></th>
	<th><?php echo $paginator->sort(__('Area',true), 'location_id');?></th>
	<th><?php echo $paginator->sort(__('Image',true), 'ad_image_id');?></th>
	<th><?php echo $paginator->sort(__('User',true), 'user_id');?></th>
	<th><?php echo $paginator->sort(__('Active',true), 'active');?></th>
	<th><?php echo $paginator->sort(__('Created',true), 'created');?></th>
	<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($adPosts as $adPost):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
			<?php echo $adPost['AdPost']['id']; ?>
		</td>
		<td>
			<?php echo $html->link($adPost['AdCategory']['category'], array('controller'=> 'ad_categories', 'action'=>'view', $adPost['AdCategory']['id'])); ?>
		</td>
		<td>
			<?php ($adPost['AdPost']['type'] == 'W') ? __('Wanted') : __('Offer'); ?>
		</td>
		<td>
			<?php echo $adPost['AdPost']['title']; ?>
		</td>
		<td>
			<?php echo substr($adPost['AdPost']['description'], 0, 150); ?>
		</td>
		<td>
            <?php echo $adPost['AdPost']['currency']; ?>
            <?php echo $adPost['AdPost']['price']; ?>
		</td>
		<td>
			<?php echo $html->link($adPost['Location']['name'], array('controller'=> 'locations', 'action'=>'view', $adPost['Location']['id'])); ?>
		</td>
		<td>
        <?php  if ($adPost['DefaultImage']['filename']) { ?>
          <center><img src="<?php e($this->base.'/img/images/s_'.$adPost['DefaultImage']['filename']); ?>" /></center>
        <?php  } ?>
		</td>
		<td>
			<?php echo $html->link(substr($adPost['User']['email'],0,5), array('controller'=> 'users', 'action'=>'view', $adPost['User']['id'])); ?>
		</td>
		<td>
			<?php ($adPost['AdPost']['active']) ? __('Yes') : __('No'); ?>
		</td>
		<td>
			<?php echo $adPost['AdPost']['created']; ?>
		</td>
		<td class="actions">
			<?php echo $html->link(__('View', true), '/adPosts/view/'.$adPost['AdPost']['id']); ?>
			<?php echo $html->link(__('Edit', true), array('action'=>'edit', $adPost['AdPost']['id'])); ?>
			<?php echo $html->link(__('Delete', true), array('action'=>'delete', $adPost['AdPost']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $adPost['AdPost']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
</div>
<div class="actions">
	<ul>
		<li><?php echo $html->link(__('List Ad Categories', true), array('controller'=> 'ad_categories', 'action'=>'index')); ?> </li>
		<li><?php echo $html->link(__('New Ad Category', true), array('controller'=> 'adCategories', 'action'=>'add')); ?> </li>
	</ul>
</div>
